<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function Name(color, brand) {
            this.color = color;
            this.brand = brand;
            this.play = function(play) {
                console.log(play);
            }
        }
        // 1、创建一个电脑对象，该对象主要有颜色、重量、品牌、型号，可以看电影、听音乐、打游戏和敲代码。
        function Computer(weight, modal) {
            this.weight = weight;
            this.modal = modal;
        }
        var n = new Name('黑色', '神州');
        var com = new Computer('2kg', '战神');
        console.log(n.color);
        console.log(com.weight);
        console.log(n['brand']);
        console.log(com['modal']);
        n.play('看电影');
        n.play('听音乐');
        n.play('打游戏');
        n.play('敲代码');

        // 2、创建一个按钮对象，该对象中需要包含宽、高、背景颜色和点击行为
        function Buttom(bgc, width, height) {
            this.bgc = bgc;
            this.width = width;
            this.height = height;
        }
        var bt = new Buttom('pink', '20px', '10px');
        console.log(bt.bgc);
        console.log(bt['width']);
        console.log(bt.height);
        n.play('点击');

        // 3、创建一个车的对象，该对象要有重量、颜色、牌子，可以载人、拉货和耕田
        function Car(weight) {
            this.weight = weight;
            this.action = function(action) {
                console.log(action);
            }
        }
        var c = new Car('3t');
        var name = new Name('黑色', '大众');
        console.log(c.weight);
        console.log(name.color);
        console.log(name['brand']);
        n.play('载人');
        n.play('拉货');
        n.play('耕田');
    </script>
</head>

<body>

</body>

</html>